package gwtI18nEditor;

import gwtI18nEditor.datamodel.Directory;
import gwtI18nEditor.datamodel.Locale;
import gwtI18nEditor.filetools.ProjectParser;
import gwtI18nEditor.screens.MainScreen;

import java.io.File;

public class Main {

	private static MainScreen mainScreen;
	private static File       curProject = null;

	public static void main(String[] args) {
		mainScreen = new MainScreen();
		if (args.length>0) {
			String projectPath = args[0];
			File directory = new File(projectPath);
			openProject(directory);
		}
	}

	public static void openProject(File directory) {
		if (directory==null) return;
		curProject = directory;
		Directory.ROOT.clear();
		Directory.ROOT.setFile(directory);
		System.out.println("Parsing directory to look for message files");
		int count = ProjectParser.parseDirectory(directory, Directory.ROOT);
		System.out.println("Found "+count+" message file(s)");
		Directory.ROOT.check(null, new Locale("de", null));
		mainScreen.updateDirectoryContent(Directory.reROOT());
	}

	public static void refreshProject() {
		openProject(curProject);
	}
}
